<template>
  <el-card class="form-container" shadow="never">
    <el-form ref="ruleForm" :model="ruleForm" :rules="rules" label-width="110px" class="demo-ruleForm">
      <el-form-item label="发货点名称：" prop="name">
        <el-input v-model="ruleForm.name" style="width:426px" />
      </el-form-item>
      <el-form-item label="发货人姓名:" prop="name">
        <el-input v-model="ruleForm.name" style="width:426px" />
      </el-form-item>


      <el-form-item label="所在区域:" prop="name">
        <el-cascader
          v-model="value"
          :options="options"
          style="width:426px"
          @change="handleChange"
        />
      </el-form-item>
      <el-form-item label="详细地址:" prop="name">
        <el-input v-model="ruleForm.name" style="width:426px" type="textarea" />
      </el-form-item>
      <el-form-item label="联系电话:" prop="name">
        <el-input v-model="ruleForm.name" style="width:426px" />
      </el-form-item>


      <el-form-item>
        <el-button type="primary" style="width:100px;margin-right:10px" @click="submitForm('ruleForm')">保存</el-button>
        <el-button style="width:100px" @click="()=>{this.$router.push({name:'Warehouse'})}">取消</el-button>
      </el-form-item>
    </el-form>
  </el-card>

</template>

<script>

import options from '@/utils/cities'
export default {
  name: 'SetupMemberAdd',
  data() {
    return {
      ruleForm: {
        name: '',
        region: '',
        date1: '',
        date2: '',
        delivery: false,
        type: [],
        resource: '',
        desc: ''
      },
      value: [],
      options,
      rules: {
        name: [
          { required: true, message: '请输入活动名称', trigger: 'blur' },
          { min: 3, max: 5, message: '长度在 3 到 5 个字符', trigger: 'blur' }
        ],
        region: [
          { required: true, message: '请选择活动区域', trigger: 'change' }
        ],
        date1: [
          { type: 'date', required: true, message: '请选择日期', trigger: 'change' }
        ],

        resource: [
          { required: true, message: '请选择活动资源', trigger: 'change' }
        ],

      }

    }
  },
  beforeMount() {

  },
  methods:{
    handleChange(value) {
      console.log(value)
    },
    submitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          alert('submit!')
        } else {
          console.log('error submit!!')
          return false
        }
      })
    },
  },

}
</script>

<style lang="scss">
@import './index';
</style>
